package com.test.daily.leetcode.y2022.m07.day0704.v08;

/**
 * @author Tom on 2022/7/4
 */
public class Solution {
    public static class Node{
        int value;
        Node next;
        public Node(int value){
            this.value = value;
        }
    }
    public static class DoubleNode{
        int value;
        DoubleNode next;
        DoubleNode last;
        public DoubleNode(int value){
            this.value = value;
        }
    }
    public static DoubleNode reverseDpubleNode(DoubleNode head){
        DoubleNode last = null;
        DoubleNode next = null;
        DoubleNode cur = head;
        while(cur != null){
            next = cur.next;
            cur.next = last;
            cur.last = next;
            last = cur;
            cur = next;
        }
        return last;
    }
    public static Node reverse(Node root){
        Node pre = null;
        Node cur = root;

        while(cur!= null){
            Node next = root.next;
            root.next = pre;
            pre = root;
            root = next;
        }
        return pre;
    }

}
